#ifndef DETECT_CLIQUES_H
#define DETECT_CLIQUES_H

#include <string>
#include <vector>
#include <iostream>
#include <boost/shared_ptr.hpp>

#include "cmdline.h"
#include "detect_nodes.h"

class CliqueDetector
{
public:
	struct Clique
	{
		Clique() {}
		std::vector<NodeDetector::FeatureSetPtr> labellings;
	};
	typedef boost::shared_ptr<Clique> CliquePtr;
	class Event
	{
	public:
		Event(NodeDetector::ChartPtr c) 
		: length(c->features.size()), width(c->labels), 
		cliques(length-1), node_chart(c) 
		{}

		int length;
		int width;
		std::vector<std::vector<CliquePtr> > cliques;
		NodeDetector::ChartPtr node_chart;

		void write(std::ostream &out);
		void crf_write(std::ostream &out);
	};
	typedef boost::shared_ptr<Event> EventPtr;

public:
	CliqueDetector(boost::shared_ptr<Parameters> p);
	~CliqueDetector();

	EventPtr next();
	void skip();
	int num_features() 
	{ 
		return myNodeDetector->feature_map()->num_features(); 
	}
	FeatureMapPtr feature_map() { return myNodeDetector->feature_map(); }

private:
	EventPtr pseudo_next();
	EventPtr crf_next();

private:
	size_t mySentenceNum;
	boost::shared_ptr<Parameters> myParams;
	NodeDetectorPtr myNodeDetector;
	NodeDetector::ChartPtr myLastNodeFeatures;
};
typedef boost::shared_ptr<CliqueDetector> CliqueDetectorPtr;

#endif
